import 'package:flutter/material.dart';
import 'package:flutterapp/chapter/six/scroll_6_2_1_def_list_view.dart';
import 'package:flutterapp/chapter/six/scroll_6_2_2_builder_list_view.dart';
import 'package:flutterapp/chapter/six/scroll_6_2_3_separated_list_view.dart';
import 'package:flutterapp/chapter/six/scroll_6_2_4_Infinite_list_view.dart';
import 'package:flutterapp/chapter/six/scroll_6_2_5_fixheader_list_view.dart';
import 'package:flutterapp/utils/navigator_utils.dart';

/// ListView
class ListViewRoute extends StatefulWidget {
  @override
  _ListViewRouteState createState() => _ListViewRouteState();
}

class _ListViewRouteState extends State<ListViewRoute> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("ListView"),
      ),
      body: _ListViewRouteBody(),
    );
  }
}

class _ListViewRouteBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
        child: Container(
            margin: EdgeInsets.only(left: 20.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                RaisedButton(
                    child: Text("默认构造函数"),
                    onPressed: () => NavigatorUtil.goPageByPush(
                        context, DefaultListViewRoute())),
                RaisedButton(
                    child: Text("ListView.builder"),
                    onPressed: () => NavigatorUtil.goPageByPush(
                        context, BuilderListViewRoute())),
                RaisedButton(
                    child: Text("ListView.separated"),
                    onPressed: () => NavigatorUtil.goPageByPush(
                        context, SeparatedListViewRoute())),
                RaisedButton(
                    child: Text("无限加载列表"),
                    onPressed: () => NavigatorUtil.goPageByPush(
                        context, InfiniteListView())),
                RaisedButton(
                    child: Text("固定表头"),
                    onPressed: () => NavigatorUtil.goPageByPush(
                        context, FixHeaderListView())),
              ],
            )));
  }
}
